﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;

namespace asp.netWebFroms
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            var uid = login1.UserName.Trim();
            var pwd = login1.Password.Trim();

            var sql = string.Format("select * from Users where Username='{0}' and Password='{1}'",uid,pwd);
            var dt = DbHelper.Table(sql);

            if (dt.Rows.Count>0)
            {
                var row = dt.Rows[0];
                var IsActived = (bool)row.ItemArray[3];
                var IsDeleted = (bool)row.ItemArray[4];
                if (IsDeleted)
                {
                   MessageBox.Show("你的账号已被注销","提示");
                }
                else
                {
                    if (IsActived)
                    {
                        MessageBox.Show("登录成功", "提示");
                        Response.Redirect("Default.aspx");
                    }
                    else
                    {
                        MessageBox.Show("你的账号已被封禁，有问题请联系客服", "提示");
                    }
                }
            }
            else
            {
                MessageBox.Show("账号或密码错误", "提示");
            }

        }

        protected void register_Click(object sender, EventArgs e)
        {
            Response.Redirect("Register.aspx");
        }
    }
}